"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Room = exports.ConferenceModeEnums = void 0;
const Member_1 = require("./Member");
const types_1 = require("../utils/types");
var ConferenceModeEnums;
(function (ConferenceModeEnums) {
    ConferenceModeEnums["SNATCH"] = "SNATCH";
    ConferenceModeEnums["POLLING"] = "POLLING";
    ConferenceModeEnums["DEFAULT"] = "DEFAULT";
})(ConferenceModeEnums = exports.ConferenceModeEnums || (exports.ConferenceModeEnums = {}));
class Room extends types_1.RoomInterface {
    constructor() {
        super(...arguments);
        this.members = {};
        this.media = {};
        this.conferenceMode = ConferenceModeEnums.DEFAULT;
        this.speaker = null;
    }
    setMember(member) {
        if (member instanceof Member_1.Member) {
            this.members[member.userId] = member;
        }
        else {
            this.members[member.userId] = new Member_1.Member(member);
        }
    }
    getMember(userId) {
        return this.members[userId];
    }
    hasSpeaker() {
        return !!this.speaker;
    }
    setSpeaker(speaker) {
        if (!this.hasSpeaker()) {
            this.speaker = speaker;
        }
        else {
            console.error('speaker is ');
        }
    }
    getSpeaker() {
        return this.speaker;
    }
    removeSpeaker() {
        this.speaker = null;
    }
    removeMember(userId) {
        delete this.members[userId];
    }
    getMembers() {
        const { members } = this;
        const __members = [];
        for (const userId in members) {
            if (members.hasOwnProperty(userId)) {
                __members.push(members[userId]);
            }
        }
        return __members;
    }
    setMediaOption(mediaOptions) {
        this.media = mediaOptions;
    }
    getMediaOption() {
        return this.media;
    }
}
exports.Room = Room;
